//179000629 徐阳光

// 实现左侧对联广告
var ad_width = "100px";//宽
var ad_height = "250px";//高
var ad_img = "img/ad1.jpg";//对联广告图片
var close_img = "img/close.png";//关闭广告按钮

// 实现右侧对联广告
var adr_width = "300px";//宽
var adr_height = "250px";//高
var adr_img = "img/ad2.jpg";//右侧对联广告图片

//创建左侧广告容器
var ad_left = document.createElement("div");
ad_left.style.float = "left";
ad_left.style.width = ad_width;
ad_left.style.height = ad_height;
ad_left.style.padding = "0px";
ad_left.style.position = "absolute";//绝对定位
ad_left.style.left = "30px";
ad_left.style.top = "20px";

//创建右侧广告容器
var ad_right = document.createElement("div1");
ad_right.style.float = "left";
ad_right.style.width = adr_width;
ad_right.style.height = adr_height;
ad_right.style.padding = "0px";
ad_right.style.position = "absolute";//绝对定位
ad_right.style.right = "30px";
ad_right.style.top = "20px";

//创建img元素,加入到ad_left中作为广告图片
var adimg = document.createElement("img");
adimg.src = ad_img;
ad_left.appendChild(adimg);

//创建img元素,加入到ad_right中作为广告图片
var adimgr = document.createElement("img");
adimgr.src = adr_img;
ad_right.appendChild(adimgr);

//创建关闭按钮加入到ad_left中
var closeimg = document.createElement("img");
closeimg.src = close_img;//图片路径
closeimg.style.width = "50px";
closeimg.style.position = "relative"//相对定位
closeimg.style.left = "50px";
closeimg.style.top = "-20px";
closeimg.style.cursor = "pointer";
ad_left.appendChild(closeimg);//在close_img后插入closeimg

//创建关闭按钮加入到ad_right中
var closeimg = document.createElement("img");
closeimg.src = close_img;//图片路径
closeimg.style.width = "50px";
closeimg.style.position = "relative"//相对定位
closeimg.style.left = "250px";
closeimg.style.top = "-20px";
closeimg.style.cursor = "pointer";
ad_right.appendChild(closeimg);//在close_img后插入closeimg

//将ad_left添加到html中
document.documentElement.appendChild(ad_left);

//将ad_right添加到html中
document.documentElement.appendChild(ad_right);

//点击关闭按钮 关闭左侧广告
closeimg.addEventListener("click",function(){
	ad_left.addEventListener("click",function(){
		this.style.display = "none";
	});
});

//点击关闭按钮 关闭右侧广告
closeimg.addEventListener("click",function(){
	ad_right.addEventListener("click",function(){
		this.style.display = "none";
	});
});




//对联广告随滚动条滚动
window.addEventListener("scroll",function(){
	var st1 = document.documentElement.scrollTop||document.body.scrollTop;
	var st2 = document.documentElement.scrollTop||document.body.scrollTop;
	ad_left.style.top = (st1 + 20) + "px";
	ad_right.style.top = (st2 + 20) + "px";
});


// var ShowMsg={
// 				title:'这是小广告',
// 				content:'还是小广告',
// 				width:'300px',
// 				height:'100px',
// 				setTitle:function(value){
// 					this.title=value;
// 				},
// 				setContent:function(value){
// 					this.content=value;
// 				},
// 				getTitle:function(){
// 					return this.title;
// 				},
// 				getContent:function(){
// 					return this.content;
// 				},
// 				show:function(){
// 					//弹窗div
// 					var _winPopDiv = document.createElement('div');  
// 						_winPopDiv.id="_winPopDiv";  
// 						_winPopDiv.style.cssText = 'width:300px; position:absolute; right:0; bottom:0; border:1px solid #666; margin:0; padding:1px; overflow:hidden; display:block;';
					
// 					//消息标题div
// 					var _titleDiv= document.createElement('div');  
// 						_titleDiv.id="_titleDiv";   
// 						_titleDiv.innerHTML=this.getTitle();  
// 						_titleDiv.style.cssText = 'width:100%; height:30px; line-height:20px; font-weight:bold; text-align:left; font-size:18px;';  
// 						_winPopDiv.appendChild(_titleDiv);
					
// 					//关闭弹窗按钮
// 					var _closeImg = document.createElement("img");
// 					_closeImg.id = "_closeImg";
// 					_closeImg.src = "img/close.png";
// 					_closeImg.style.cssText = 'position:absolute; right:4px; top:1px; color:#FFF; cursor:pointer;font-size:14px;';
// 					_titleDiv.appendChild(_closeImg);
					
					
// 					//内容div
// 					var _conDiv= document.createElement('div'); 
// 						_conDiv.id="_conDiv";  
// 						_conDiv.style.cssText = 'width:100%; height:110px; line-height:80px; font-weight:bold; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center;';  
// 						_conDiv.innerHTML=this.getContent();
// 						_winPopDiv.appendChild(_conDiv);    
// 					document.body.appendChild(_winPopDiv);  
				    
// 					//关闭span绑定事件
// 					var closeDiv = document.getElementById("_closeImg");
// 					if(closeDiv.addEventListener){
// 						closeDiv.addEventListener("click",function(e){ 
// 							if (window.event != undefined) {  
// 								window.event.cancelBubble = true;  
// 							} else if (e.stopPropagation) {  
// 								e.stopPropagation();  
// 							}  
// 							document.getElementById('_winPopDiv').style.cssText="display:none;";
// 						},false);
// 					}else if(closeDiv.attachEvent){
// 						closeDiv.attachEvent("onclick",function(e){  
// 							if (window.event != undefined) {  
// 								window.event.cancelBubble = true;  
// 							} else if (e.stopPropagation) {  
// 								e.stopPropagation();  
// 							}  
// 							document.getElementById('_winPopDiv').style.cssText="display:none;";
// 						});
// 					}
// 				}
// 			};
// 			ShowMsg.show();






















